﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Starksoft.Net.Ftp;
using System.IO;

namespace FtpDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            Starksoft.Net.Ftp.FtpClient ftp = new Starksoft.Net.Ftp.FtpClient("task.51try.top", 2121, Starksoft.Net.Ftp.FtpSecurityProtocol.None);
            ftp.CharacterEncoding = Encoding.Default;
            using (ftp)
            {
                ftp.Open("task.51try.top", "task.51try.top123321");
                FtpItemCollection coll = ftp.GetDirList("task.51try.top/log");

                string dir = @"D:\logs\";

                foreach (var item in coll)
                {
                    Console.WriteLine(item.Name);
                    if (item.Name.Contains("301跳转日志"))
                    {
                        string path = Path.Combine(dir, item.Name);
                        ftp.GetFile(item.FullPath, path);
                    }
                }
            }
            Console.WriteLine("------------------------------------------完成------------------------------------------");
        }
    }
}
